import { Component, OnInit } from '@angular/core';
  import { NzModalRef, NzMessageService } from 'ng-zorro-antd';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MarketMomentService } from '@core/routes-services/market-moment.service';

  @Component({
    selector: 'app-market-moments-market-moments-detail',
    templateUrl: './market-moments-detail.component.html',
    styles: [`
    h2 {
      border-bottom: 1px solid #1890ff;
      color: #1890ff;
      padding-top: 10px;
    }
  `],
  })
  export class MarketMomentsDetailComponent implements OnInit {

    entity: any = {};
    validateForm: FormGroup;
    isLoading: boolean = true;
    imgs: any [] = []

    constructor(private fb: FormBuilder,
                private modal: NzModalRef,
                private marketMomentService: MarketMomentService,
                public message: NzMessageService,) {
    }

    ngOnInit(): void {
      console.log(this.entity)
      let that = this;
      if(this.entity.imgKeys){
        this.imgs = this.entity.imgKeys.split(',');
      }
      setTimeout(function () {
        that.isLoading = false;
      }, 300)
      this.validateForm = this.fb.group({
        shopId: [this.entity.shopId, [Validators.required]],
      });
    }
    submitForm(): void {
      if (this.validateForm.invalid) {
        for (const i in this.validateForm.controls) {
          this.validateForm.controls[i].markAsDirty();
          this.validateForm.controls[i].updateValueAndValidity();
        }
      } else {

      }
    }

    picList: any [] = [];
    isShowPic: boolean = false;

    showPic(key) {
      this.picList = [];
      this.picList.push({imgKey: key});
      this.isShowPic = true
    }

    onPicClose(res) {
      this.isShowPic = res
      this.isShowPic = false
    }

    close() {
      this.modal.destroy();
    }
  }
